import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
import VideoSurface 1.0
import QtMultimedia 5.12
import VideoCapturer 1.0
import ScreenRecoder 1.0
import QtQml 2.3

import "."

Window {
    id:root_window
    width: 800
    height: 600
    visible: true
    title: qsTr("Hello World")

    BaseSurface {
        id: surface
        anchors.top: menu.bottom
        anchors.bottom: parent.bottom
        width: parent.width
        source: capturer
    }

    CameraMenu{
        id:menu
        width: parent.width
        height: 35
        onOpenCamera: {
            console.log(device_name)
            capturer.open(device_name)

            root_window.setGeometry(0,0,1920/Screen.devicePixelRatio,1080/Screen.devicePixelRatio);
        }

        onInsertWord: {
            insert_word.visible = true;
        }
    }

    // 相机
    VideoCapturer {
        id: capturer
    }


    // 插入文字对话框
    InsertWord {
        id: insert_word
        width: 768
        height: 400
        visible: false

        // 收到插入文字信号
        onInsertWords: {
            let component = Qt.createComponent("MovableLabel.qml")
            if(component.status === Component.Ready){
                component.createObject(surface, {text:text, font:font, color:color})
            }
        }
    }
}
